package com.yanqu.road.server.cmd.activity.hsisland.cross;

import com.yanqu.road.entity.enums.eMailType;
import com.yanqu.road.entity.player.UserInfo;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.HsIslandProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.logic.mail.MailManager;
import com.yanqu.road.server.manger.MultipleLanguageMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Cmd(code = Protocol.S_HS_ISLAND_KILL_BOSS_DAMAGE_RANK_MAIL_REWARD,desc = "海神岛-跨服返回-邮件补发boss榜单奖励")
public class HsIslandKillBossDamageRankMailRewardCmd implements Command {

    protected static Logger log = LogManager.getLogger(HsIslandKillBossDamageRankMailRewardCmd.class.getName());

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage yanQuMessage) throws Exception {
        HsIslandProto.HsIslandKillBossDamageRankMailRewardMsg reqMsg = HsIslandProto.HsIslandKillBossDamageRankMailRewardMsg.parseFrom(yanQuMessage.getBytes());

        UserInfo userInfo = UserMgr.getUserInfo(reqMsg.getUserId());
        if (userInfo == null) {
            log.error("HsIslandKillBossDamageRankMailRewardCmd: userInfo is null ,userId:{}", reqMsg.getUserId());
            return;
        }

        // 发个邮件
        String mailTitle = MultipleLanguageMgr.getContent("HS_ISLAND_MAIL_TITLE_1", userInfo.getLanguage());
        String mailContent = MultipleLanguageMgr.getContent("HS_ISLAND_CONTENT_1", userInfo.getLanguage());
        // 奖励
        MailManager.sendMail(reqMsg.getUserId(), eMailType.SYSTEM.getValue(), reqMsg.getReward(), mailContent, mailTitle);
    }
}
